home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / CPP / VCW411.ZIP / SHAPE.H < prev    next >
Encoding:
C/C++ Source or Header  |  1995-11-29  |  4.0 KB  |  166 lines

  1. #ifndef   SHAPE_H
  2. #define   SHAPE_H
  3.  
  4. // -[Keep_Heading]-
  5.  
  6. // -[Copyright_Mesg]-
  7. // --------------------------------------------------------------- //
  8. // (c) Copyright 1993-1994. Step Ahead Software Pty Limited. All rights reserved.
  9. // Class Name  : Shape
  10. // Designer    : Example Writer
  11. // Filename    : SHAPE.h
  12. // Description : 
  13. // Base class for all shapes. The pure virtual function Show is redefined
  14. // in derived classes for their individual needs.
  15. //
  16. // Future enhancements - double click on an object to change its colour,
  17. // drag the corners to size the object.
  18. // --------------------------------------------------------------- //
  19.  
  20. // ==================================================
  21. // = LIBRARY
  22. // Step 3 Graphics Example
  23. // = FILENAME
  24. // SHAPE.cpp
  25. // = RCSID
  26. // $Id$
  27. // = AUTHOR
  28. // Example Writer
  29. // = COPYRIGHT
  30. // (c) Copyright 1993-1994. Step Ahead Software Pty Limited. All rights reserved.
  31. // ==================================================
  32. #define    CC_GEN    1
  33. #include    <OBJECT.h>
  34. #include    <OBJSTRM.h>
  35.  
  36.  
  37. // -[Keep_h_Extras]-
  38. #include    <windows.h>
  39. #include    <iostream.h>
  40.  
  41. // -[Class_Dec]-
  42. class Shape;
  43. typedef Shape * PShape;
  44. typedef Shape & RShape;
  45. typedef Shape * & RPShape;
  46. typedef const Shape * PCShape;
  47. typedef const Shape & RCShape;
  48.  
  49.  
  50. class Shape : public Object, public TStreamable
  51. // = TITLE
  52. // Shape
  53. // = CLASSTYPE
  54. // Abstract
  55. // = AUDIENCE
  56. // 
  57. // = DESCRIPTION
  58. // Base class for all shapes. The pure virtual function Show is redefined
  59. // in derived classes for their individual needs.
  60. //
  61. // Future enhancements - double click on an object to change its colour,
  62. // drag the corners to size the object.
  63. // 
  64. // = NOTES
  65. // 
  66. // = SEE ALSO
  67. // Object, TStreamable
  68. {
  69. // -[Keep_Class_Extras]-
  70.  
  71.  
  72. // -[Member_Data_Decs]-
  73.   public:
  74.   protected:
  75.  
  76.     // The colour in which the shape is to be painted.
  77.     COLORREF Colour;
  78.  
  79.     // Height of the shape.
  80.     int Height;
  81.  
  82.     // Remembers the initial value of X so that the shape can return
  83.     // home when GoHome is called.
  84.     int HomeX;
  85.  
  86.     // Remembers the initial value of Y so that the shape can return
  87.     // home when GoHome is called.
  88.     int HomeY;
  89.  
  90.     // Width of the shape.
  91.     int Width;
  92.  
  93.     // X coordinate of the position of the shape.
  94.     int X;
  95.  
  96.     // Y coordinate of the shape's position.
  97.     int Y;
  98.   private:
  99.   public:
  100.  
  101.  
  102. // -[Member_Function_Decs]-
  103.   public:
  104.  
  105.     // Constructs an object and sets its X, Y, HomeX and HomeY values.
  106.     // Colour is initialised to blue (0x00FF0000)
  107.     Shape(int XCoordinate, int YCoordinate);
  108.  
  109.     // Moves a shape back home.
  110.     virtual void GoHome(HWND HWindow);
  111.  
  112.     // Returns TRUE if shape is currently at home coordinates.
  113.     virtual BOOL isHome() const;
  114.  
  115.     // Returns TRUE if the point falls within the shape's bounding rectangle.
  116.     virtual BOOL isIn(POINT Pnt);
  117.  
  118.     // Erases the object at the current position and Shows it at the
  119.     // new position.
  120.     virtual void MoveTo(HWND HWindow, int NewX, int NewY);
  121.  
  122.     // Sets the new colour of the shape. It returns the previous colour.
  123.     // By default the Colour is Black (0x00000000)
  124.     virtual COLORREF SetColour(COLORREF);
  125.  
  126.     // Shows a shape in the given display context at the location which
  127.     // is specified by the value of the X,Y members.
  128.     virtual void Show(HDC hDC) = 0;
  129.   protected:
  130.   private:
  131.  
  132.  
  133. // -[Persistent_1]-
  134.   // OWL1.0 Streamability
  135.   public:
  136.     Shape(StreamableInit); // Used to create a new object  protected:
  137.     // Reads data in from the stream
  138.     virtual Pvoid read(Ripstream is);    // Writes data out to the stream
  139.     virtual void write(Ropstream os);
  140. };
  141.  
  142. // -[Persistent_2]-
  143. // OWL1.0 Streamability
  144. inline Ripstream operator >> ( Ripstream is, RShape cl )
  145.   { return is >> (RTStreamable)cl; }
  146. inline Ripstream operator >> ( Ripstream is, RPShape cl )
  147.   { return is >> (RPvoid)cl; }
  148. inline Ropstream operator << ( Ropstream os, RCShape cl )
  149.   { return os << (RTStreamable)cl; }
  150. inline Ropstream operator << ( Ropstream os, PCShape cl )
  151.   { return os << (PTStreamable)cl; }
  152.  
  153.  
  154. // -[Keep]-
  155.  
  156.  
  157. // -[Global_Data_Decs]-
  158.  
  159.  
  160. // -[Global_Function_Decs]-
  161.  
  162. // -[Function_Defs]-
  163.  
  164. // -[End_Cond]-
  165. #endif
  166.